<template>
  <div class="divBox" style="background: #F0F2F5; padding: 0 20px 20px;">
    <base-info ref="baseInfo" class="mb15" />
    <companyStatistic></companyStatistic>
  </div>
</template>

<script>
import { merchantStockApi, merchantVisitApi } from "@/api/home";
import { mapGetters } from "vuex";
import baseInfo from "./components/baseInfo";
import companyStatistic from "./components/companyStatistic";
export default {
  name: "Dashboard",
  components: { baseInfo, companyStatistic },
  data() {
    return {
      merTitle: "商品销量排行",
      visitTitle: "商户访客量排行",
      currentRole: "adminDashboard",
      grid: {
        xl: 8,
        lg: 8,
        md: 12,
        sm: 12,
        xs: 24
      },
      merchantStock: [],
      merchantVisit: []
    };
  },
  computed: {
    ...mapGetters(["roles"])
  },
  mounted() {
    // this.getList("lately30");
    // this.getVisit("lately30");
  },
  methods: {
    // 商品销量
    getList(val) {
      merchantStockApi({ date: val })
        .then(res => {
          if (res.status === 200) {
            this.merchantStock = res.data.list;
          }
        })
        .catch(res => {
          this.$message.error(res.message);
        });
    },
    // 商户访客量
    getVisit(val) {
      merchantVisitApi({ date: val })
        .then(res => {
          if (res.status === 200) {
            this.merchantVisit = res.data.list;
          }
        })
        .catch(res => {
          this.$message.error(res.message);
        });
    }
  }
};
</script>
